Skip to content

Fix: replace reachable assert with error return in header field callbacks and bump llhttp to v9.3.1 - #204

Merged
felicityzhao9 merged 7 commits into
FreeRTOS:mainfrom
felicityzhao9:llhttp-bump
Mar 25, 2026
Merged

felicityzhao9 merged 7 commits into
FreeRTOS:mainfrom
felicityzhao9:llhttp-bump

Conversation

@felicityzhao9

@felicityzhao9 felicityzhao9 commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Changes made

1. llhttp submodule bump (v6.1.1 → v9.3.1)

  • source/dependency/3rdparty/llhttp — updated to release/v9.3.1

2. Defensive zero-length header field handling (the actual security fix)

  • findHeaderFieldParserCallback() (line ~2329) — replaced the assert(fieldLen > 0U)
    with a proper error return via LLHTTP_STOP_PARSING
  • httpParserOnHeaderFieldCallback() (line ~717) — added the same zero-length guard
    with LLHTTP_STOP_PARSING

Test Steps

  • Builds cleanly against llhttp v9.3.1
  • PoC created from the ticket no longer crashes

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: WOW did llhttp really grow in size

@felicityzhao9
felicityzhao9 merged commit 036cbf6 into FreeRTOS:main Mar 25, 2026
11 checks passed
kstribrnAmzn added a commit to kstribrnAmzn/coreHTTP that referenced this pull request Nov 17, 2026
When a transport receive ends exactly at the end of a header field name,
llhttp reopens the field span at the start of the next llhttp_execute()
buffer and closes it at the ':' separator, invoking on_header_field with
a length of zero. This is a valid streaming continuation of the field.

The zero-length guard added to httpParserOnHeaderFieldCallback() in FreeRTOS#204
rejected every zero-length callback with LLHTTP_STOP_PARSING, so valid
responses failed with HTTPParserInternalError whenever a receive boundary
fell right after a header field name (including byte-at-a-time receives).

Only reject a zero-length field when no header field is in progress.
Genuinely empty header field names are still rejected by llhttp itself
(HTTPSecurityAlertInvalidCharacter) before any span callback fires.

Add a unit test that splits the response at the end of a header field
name and expects the response to parse successfully.
kstribrnAmzn added a commit that referenced this pull request Nov 17, 2026
…es (#210)

When a transport receive ends exactly at the end of a header field name,
llhttp reopens the field span at the start of the next llhttp_execute()
buffer and closes it at the ':' separator, invoking on_header_field with
a length of zero. This is a valid streaming continuation of the field.

The zero-length guard added to httpParserOnHeaderFieldCallback() in #204
rejected every zero-length callback with LLHTTP_STOP_PARSING, so valid
responses failed with HTTPParserInternalError whenever a receive boundary
fell right after a header field name (including byte-at-a-time receives).

Only reject a zero-length field when no header field is in progress.
Genuinely empty header field names are still rejected by llhttp itself
(HTTPSecurityAlertInvalidCharacter) before any span callback fires.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants